package main.java.ssm.service.impl;

import org.springframework.stereotype.Service;
import ssm.dao.UserDao;
import ssm.entity.User;
import ssm.service.UserService;

import javax.annotation.Resource;
import java.util.List;

/**
 * Author: AD
 * Date: 17-6-5.
 */
@Service("userService")
public class UserServiceImpl implements UserService {

    @Resource
    private UserDao userDao;

    @Override
    public User getUserById(int userId)
    {
        return this.userDao.selectByPrimaryKey(userId);
    }

    //继承并重写方法
    @Override
    public void deleteUserById(int userId) {

        userDao.deleteByPrimaryKey(userId);
    }


    @Override
    public User updateUserById(User record) {
        userDao.updateByPrimaryKey(record);
        return record;
    }



    @Override
    public int addUser(User user) {
       return userDao.insertSelective(user);

    }



    @Override
    public List<User> findAll() {
        return userDao.selectAll();
    }




    @Override
    public User findById(int userId) {
        return userDao.selectByPrimaryKey(userId);
    }




    @Override
    public String findPassByName(String username) {
        return userDao.findPasswordByUsername(username);
    }
}
